﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    $(function() {
        $(".datepicker").datepicker();
        tableSelectOrder("#msgreceivelist .table_style");
    })
</script>

<script type="text/javascript">
    $(function() {
        var msgreceivelistoptions = {
            url: "/Message/MsgReceiveList",
            type: "POST",
            success: function(data) {
                $("#workarea-msg-4").html(data);
            }
        };

        $("#frmmsgreceivelist").ajaxForm(msgreceivelistoptions);
    })

    // 查看信息
    function msgreceiveshow(msg_id) {
        $.ajax({
            type: "POST",
            url: "/Message/MsgShow",
            data: { "msg_id": msg_id },
            success: function(data) {
                addtab('msg-4-1', '站内信');
                $("#workarea-msg-4-1").html(data);
            }
        })
    }
</script>

<div id="msgreceivelist" style="padding-top: 35px;">
    <%using (Html.BeginForm("MsgReceiveList", "Message", FormMethod.Post, new { id = "frmmsgreceivelist" }))
      { %>
    <div class="selectpanel" style="margin: 5px 20px 5px 70px;">
        标题:
        <%=Html.TextBox("searchtitle_msgreceive")%>
        内容:
        <%=Html.TextBox("searchcontent_msgreceive")%>
        接收时间:
        <%=Html.TextBox("searchstime_msgreceive", "", new { @class = "datepicker" })%>
        -
        <%=Html.TextBox("searchetime_msgreceive", "", new { @class = "datepicker" })%>
        <input class="btn_style" type="submit" value="查询" name="submit" />
    </div>
    <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <th>
                    标题
                </th>
                <th>
                    发起人
                </th>
                <th>
                    接收时间
                </th>
                <th>
                    消息状态
                </th>
                <th>
                </th>
            </tr>
        </thead>
        <tbody>
            <%
                System.Data.DataTable dt = ViewData["dt"] as System.Data.DataTable;
                if (dt == null || dt.Rows.Count == 0)
                { %>
            <tr>
                <td colspan="0" style="text-align: center;">
                    当前无数据！
                </td>
            </tr>
            <%}
                else
                {
                    int count = dt.Rows.Count;
                    for (int i = 0; i < count; i++)
                    {
            %>
            <tr>
                <td>
                    <%=dt.Rows[i]["标题"]%>
                </td>
                <td>
                    <%=dt.Rows[i]["发起人"]%>
                </td>
                <td>
                    <%=DateTime.Parse(dt.Rows[i]["发送时间"].ToString()).ToString("yyyy-MM-dd HH:mm")%>
                </td>
                <td>
                    <%=dt.Rows[i]["已读"].ToString().Trim() == "1" ? "已读" : "未读"%>
                </td>
                <td>
                    <a class="btn_detail" onclick="msgreceiveshow(<%= dt.Rows[i]["编码"] %>)">查看</a>
                </td>
            </tr>
            <%
                }
                } %>
        </tbody>
    </table>
    <div id="pageLink">
        <%var pageInfo = ViewData["pageInfo"] as PagingInfo; %>
        <%if (pageInfo != null)
          { %>
        <%=Ajax.PageLinks(pageInfo, index => Url.Action("MsgReceiveList", new
        {
            page = index,
            title = ViewData["searchtitle_msgreceive"],
            content = ViewData["searchcontent_msgreceive"],
            stime = ViewData["searchstime_msgreceive"],
            etime = ViewData["searchetime_msgreceive"]
        }), new AjaxOptions { UpdateTargetId = "workarea-msg-4" })%>
        <%} %>
    </div>
    <%} %>
</div>
